<template>
  <div class="toolbar w-100 flex align-center justify-between">
    <div class="flex gc-2"> </div>
    <div class="flex-1 text-center">
      <input v-model="currentLink.src" type="text" :disabled="true" />
    </div>
    <div class="flex gc-4">
      <div
        class="icon-button"
        title="新的浏览器中打开"
        @click="openLink(currentLink.src)"
      >
        <img :src="browser" width="18" />
      </div>
      <div class="icon-button" title="刷新" @click="refresh">
        <img :src="refreshPng" width="18" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import browser from '@/assets/images/browser.png';
  import refreshPng from '@/assets/images/refresh.png';
  import { openLink } from '@/utils/utils';
  import { currentLink, links } from '../bus';

  const refresh = () => {
    links.value = links.value.map((e) => {
      if (currentLink.value.id === e.id) {
        e.update += 1;
      }
      return e;
    });
  };
</script>

<style lang="scss" scoped>
  .toolbar {
    background-color: #f8f8f8;
    height: 48px;
    padding: 0 12px;
    input {
      background-color: white;
      height: 28px;
      width: 420px;
      text-align: center;
      border-radius: 16px;
    }
  }
</style>
